//
//  RespBean.swift
//  Runner
//
//  Created by zzzzzzz on 2020/10/28.
//

import Foundation
import FileProvider
/**
 * 功能描述: 服务端响应的消息
 * 修改时间:
 * 修改描述:
 */
public class RespBean : IMsg{
    /**
     * 错误提示
     */
    public var message:String = "";
    
    private enum CodingKeys: String, CodingKey { case message }

    /**
     * server响应cmdId
     * 当客户端发送消息不需要服务器响应时，使用{@link ServerConst#INVALID_CMD_ID}填充该字段
     */
    private var respCmdId :Int = 0;
    
    /**
      * server响应的json
     */
    public var resultJson:String = "";
   
    /**
     * 错误码，参考{@link IMResultCode}
    */
    public var code:String = "";
     
    
    
    required init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        
        if let message = try container.decodeIfPresent(String.self, forKey: .message) {
            self.message = message;
        } else {
            self.message = "";
        }
        try super.init(from: decoder)
    }
    
    public func getMessage()->String {
        return message;
    }

    public func setMessage( message:String) {
        self.message = message;
    }


    public func toString() ->String {
        return "MsgRespBean{message='\(String(describing: message))', msgId='\(String(describing: msgId))'}";
        
        
        
        /*
         "MsgRespBean{" +
         "message='" + message + "\'" +
         ", msgId='" + msgId + "\'" +
         "}";
         */
        
    }
    
    public func getSendMsgResultMap()->[String:Any] {
        
        let msg = NSMutableDictionary();
        msg["msgId"] = msgId;
        msg["message"] = message;
        msg["code"] = (code);
        msg["respCmdId"] = respCmdId;
        msg["resultJson"] = resultJson;
        return msg as! [String : Any];
        
    }
}
